package com.wlyuan.open.scanner.domain.order;

import com.wlyuan.open.scanner.dao.entity.AttachDO;
import com.wlyuan.open.scanner.domain.attach.Attach;
import com.wlyuan.open.scanner.utils.mappings.MappingInvalid;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author lijing
 * @description
 */
public class AttachConvert {

    private static final Convert CONVERT = Mappers.getMapper(Convert.class);

    @Mapper(uses = MappingInvalid.class)
    public interface Convert {

        @Mappings({
                @Mapping(target = "type", source = "attachType"),
                @Mapping(target = "url", source = "attachUrl"),
                @Mapping(target = "name", source = "attachName"),
                @Mapping(target = "createAt", source = "attachCreatrtime"),
                @Mapping(target = "ownerOrderId", source = "attachOwnerid"),
                @Mapping(target = "remark", source = "attachRemak"),
                @Mapping(target = "createBy", source = "attachCreator"),
                @Mapping(target = "tenantId", source = "attachCompanyid"),

                @Mapping(target = "id", source = "attachId"),
                @Mapping(target = "invalid", source = "attachInvalid"),
                @Mapping(target = "syncThisTag", source = "attachSyncthistag"),
                @Mapping(target = "thisSyncTag", source = "attachThissynctag"),
        })
        Attach convert(AttachDO source);

        List<Attach> convert(List<AttachDO> list);

    }

    public static List<Attach> convert(List<AttachDO> creation) {
        return CONVERT.convert(creation);
    }

    public static Attach convert(AttachDO source) {
        return CONVERT.convert(source);
    }
}
